import request from '@/utils/request'

// 获取用户列表
export const getUserList = (data) => {
    return request({
        url: '/api/permission/Users',
        method: 'GET',
        data
    })
}

// 获取所有用户列表
export const getUserListAll = () => {
    return request({
        url: '/api/permission/Users/All',
        method: 'GET'
    })
}

// 获取用户下拉框列表(公司+部门+用户)
export const getUserSelector = () => {
    return request({
        url: '/api/permission/Users/Selector',
        method: 'GET'
    })
}

// 新建用户
export const createUser = (data) => {
    return request({
        url: '/api/permission/Users',
        method: 'POST',
        data
    })
}

// 修改用户
export const updateUser = (data) => {
    return request({
        url: `/api/permission/Users/${data.id}`,
        method: 'PUT',
        data
    })
}

// 获取用户信息
export const getUserInfo = (id) => {
    return request({
        url: `/api/permission/Users/${id}`,
        method: 'GET'
    })
}

// 删除用户
export const delUser = (id) => {
    return request({
        url: `/api/permission/Users/${id}`,
        method: 'DELETE'
    })
}

// 修改用户密码
export const resetUserPassword = (data) => {
    return request({
        url: `/api/permission/Users/${data.id}/Actions/ResetPassword`,
        method: 'POST',
        data
    })
}

// 更新用户状态
export const updateUserState = (id) => {
    return request({
        url: `/api/permission/Users/${id}/Actions/State`,
        method: 'PUT'
    })
}

// IM通讯获取用户
export const getImUser = data => {
    return request({
        url: '/api/permission/Users/ImUser',
        method: 'GET',
        data
    })
}

// 获取用户下拉框列表
export const getImUserSelector = (organizeId, keyword) => {
    return request({
        url: `/api/permission/Users/ImUser/Selector/${organizeId}`,
        method: 'post',
        data: { keyword }
    })
}

// 获取用户基本信息
export const getUserInfoList = userId => {
    return request({
        url: '/api/permission/Users/getUserList',
        method: 'post',
        data: { userId }
    })
}